home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / cross / GBDK-2.0.lha / GBDK / lib / asr.s < prev    next >
Text File  |  1998-10-01  |  401b  |  28 lines

  1.     .include    "global.s"
  2.  
  3.     .area    _CODE
  4.  
  5.     ;; 16-bit arithmetic shift right
  6.     ;; 
  7.     ;; Entry conditions
  8.     ;;   BC = value to shift
  9.     ;;   A = number of bits to shift
  10.     ;; 
  11.     ;; Exit conditions
  12.     ;;   BC = result
  13.     ;;
  14.     ;; Register used: AF,BC,DE,HL
  15. .asr16::
  16.     OR    A        ; Test if shift value is 0
  17.     RET    Z        ; If yes, return
  18. 1$:
  19.     SRA    B        ; Shift right
  20.     RR    C
  21.     DEC    A
  22.     JR    NZ,1$        ; Finished?
  23.     RET
  24.  
  25. .asr8::
  26.     LD    B,#0x00
  27.     JP    .asr16
  28.